<template>
	<view class="flex-column py-3 px-25">
		<task-item :list="list" @itemClick="itemClick"></task-item>
		<view class="fixed-bottom px-5 pb-3">
			<main-button @click="totask">发布通知</main-button>
		</view>
	</view>
</template>

<script>
	import taskItem from '../../../components/common/task-item.vue';
	import mainButton from '../../../components/common/main-buttom.vue';
	export default {
		components: {
			taskItem,
			mainButton
		},
		data() {
			return {
				list: []
			};
		},
		onPullDownRefresh() {
			this.getData()
		},
		onShow() {
			this.getData()
		},

		methods: {
			itemClick(item){
				uni.setStorageSync('taskdetail',item);
				uni.navigateTo({
					url:'../../taskdetail/taskdetail'
				})
			},
			totask() {
				uni.navigateTo({
					url: "./addtask/addtask"
				})
			},
			getData() {
				let this_ = this;
				let opts = {
					url: 'Ls/SearchLsZy.shtml'
				};
				let param = {
					bjId: uni.getStorageSync('class_id'),
					data: {
						ls_id: uni.getStorageSync('userInfo').user_id
					}
				};
				this_.$http.taskhttpTokenRequest(opts, param).then(
					res => {
						console.log(res.data);
						if (res.data.code == '200') {
							uni.stopPullDownRefresh();
							this.list = res.data.data;
						} else {
							uni.showToast({
								icon: 'none',
								title: res.data.error.returnUserMessage
							});
						}
					},
					error => {
						console.log(error);
					}
				);
			}
		}
	};
</script>

<style></style>
